package com.nanuminc.market.today;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;

import com.nanuminc.market.R;

public class TodaySearch extends Activity implements OnClickListener {

	EditText searchEdit;
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.todaysearch);

		// 포커스 적용
		searchEdit = (EditText) findViewById(R.id.search_edit);
		Button btnSearch = (Button)findViewById(R.id.btn_search);
		searchEdit.setPrivateImeOptions("defaultInputmode=korean;");
		searchEdit.requestFocus();

		// 키보드 보여주기
		InputMethodManager imm = (InputMethodManager)
		this.getSystemService(Context.INPUT_METHOD_SERVICE);
		imm.showSoftInput(searchEdit, InputMethodManager.SHOW_FORCED);
		imm.showSoftInputFromInputMethod(searchEdit.getApplicationWindowToken(),
				InputMethodManager.SHOW_FORCED);
		btnSearch.setOnClickListener(this);
		

	}

	@Override
	public void onClick(View v) {
		switch(v.getId())
		{
		case R.id.btn_search: {
			Intent intent = new Intent();
			intent.putExtra("SEARCH", searchEdit.getText().toString());
			setResult(RESULT_OK, intent);
			finish();
			break;
		}
		case R.id.btn_cancel: {
			setResult(RESULT_CANCELED);
			finish();
			break;
		}
		}
	}

}
